package com.cn.wanxi.service;

import com.cn.wanxi.dao.NavDao;
import com.cn.wanxi.model.NavModel;

public class NavService {
    public NavModel[] getNavModels() {
//        数组静态定义和动态定义？
//        什么是数组？将相同元素放在一起 可以用数组（容器）来装

//        對Java数组的赋值
//        NavModel model = new NavModel();
//        model.setTitle("");
//        model.setHref("");
//        navModels[0]=model;
//        NavModel model = new NavModel();
//        model.setTitle("");
//        model.setHref("");
//        navModels[0]=model;
//        NavModel model = new NavModel();
//        model.setTitle("");
//        model.setHref("");
//        navModels[0]=model;
        NavDao navDao = new NavDao();
        int length = navDao.getHrefs().length;
        NavModel[] navModels = new NavModel[length];

        for (int i = 0; i < length; i++) {
            NavModel model = new NavModel();
            model.setTitle(navDao.getTitles()[i]);
            model.setHref(navDao.getHrefs()[i]);
            navModels[i] = model;
        }
        return navModels;
    }

    //   static Integer nn;
    public static void main(String[] args) {
        NavModel[] navModels = new NavService().getNavModels();
//        for (int i=0;i<navModels.length;i++){
//            System.out.println(navModels[i]);
//        }
//
//        System.out.println(nn);
    }
}
